// const host ="https://hlhj.ewent.cn";
const host = "https://www.3160000.cn";

const resStatus = 200;

// 登录
export const login = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=api2&a=weixin_login",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });  
}

// 幻灯片
export const getSilder = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=api2&a=get_index_banner",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });  
}

// 蔬菜专区 OEM 简写
export const getOEM = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=api2&a=getIndexNav",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });  
}

// 商品展示
export const getCommodityShow = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=category&a=getTopCategoryList",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });  
}

// 商品分类列表
export const getGoodstype = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=category&a=getCategoryList",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },    
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });  
}

// 商品排序 + 筛选商品
export const getGoodsSort = (params, fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=category&a=async_list",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },    
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });  
}

// 右侧分类筛选菜单
export const getFilterMenu = (params,fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=category&a=top_all",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

//商品规格
export const getSpec = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=category&a=get_properties",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },    
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 加入购物车（单个商品）
export const addCart = (params,fun) =>{
  wx.request({
    url: host + "/index.php?m=api&c=flow&a=add_to_cart",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },    
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 加入购物车（多个商品）
export const MultipleItemsAddCart = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=flow&a=add_to_cart_many",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },    
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

//获取购物车详情 
export const getShoppingCartDetails = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=flow&a=cart",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 删除购物车指定商品
export const deleteShoppingCart = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=flow&a=drop_goods",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 配件商品
export const getGoodsMountings = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=category&a=get_fittings",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },   
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取我的收藏
export const getMyCollection = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=collection_list",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 收藏
export const collect = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=add_collection",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 取消收藏
export const cancelCollect = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=delete_collection",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 具体商品
export const getSpecificGoods = (params, fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=goods&a=getGoods",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 不配送区域
export const NDArea = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=goods&a=getNotShipping",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 用户评论
export const UserEstimate = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=goods&a=getComment",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}


// 个人信息
export const getUserInfo = (params, fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=getUserIndex",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 提交订单（结算页面）
export const submitOrder = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=flow&a=checkout",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}


//修改购物车指定商品数量
export const updateCart = (params, fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=flow&a=ajax_update_cart",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}


// 获取代理
export const getMyAgencyInfo = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_shop_index",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取验证码
export const getVerificationCode = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_sms",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 注册代理
export const regAgency = (params, fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=register_agent",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取联动
export const getLinkage = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_province",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 新增收货地址
export const addAddress = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=add_address",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取地址列表
export const getSite = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=address_list",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}
// 设置默认收货地址
export const setDefaultAddress = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=post_default_address",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取修改地址内容
export const getUpdateAddress = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=edit_address",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 修改地址
export const updateAddress = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=edit_address",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 删除收货地址
export const deleteSite = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=del_address_list",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

//获取代理轮播图
export const getAgencSilder = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=api2&a=get_agent_banner",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取二维码
export const getQRcode = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=drp_ewm",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取代理团队信息
export const getMyTeam = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_son_list",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取资料修改内容
export const getDatumUpdate = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_edit_info",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 修改资料
export const datumUpate = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=post_edit_info",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

//绑定手机
export const bindingMobile = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=post_user_phone",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取提现信息
export const getWithdrawDepositInfo = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_user_bank_info",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 提现
export const withdrawDeposit = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=post_user_remainder",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取所有银行卡
export const getBankCard = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_user_bank_card",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
} 

//获取银行卡名称
export const getBankCardName = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_bank_name",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  }); 
}

// 添加银行卡
export const addBankCard = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=post_user_bank_card",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  }); 
}

// 设置默认银行卡号
export const defaultBankCard = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=post_default_bank",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  }); 
}


export const hidden = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=delete_bank_card&bank_card_id=1",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  }); 
}

//微信支付
export const pay = (params,fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=flow&a=done",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 待支付
export const unpaid = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_order_pay",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  }); 
}

// 获取全部订单
export const getAllOrder = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=order_list",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取未付款订单
export const getPaymentOrder = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=not_pay_order_list",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取待收货订单
export const getStayReceivingOrder = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=not_shoushuo",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}


// 获取待评价订单
export const getStayEvaluateOrder = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=order_comment",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取订单详情
export const getOrderDetail = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=order_detail",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 确认收货
export const Receiving = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=affirm_received",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取不配送区域
export const getNoDeliverySite = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=goods&a=getNotShipping",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 添加评论
export const addEvaluate  = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=add_comment",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}


// 测试
export const myTeamSearch = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=api2&a=fff",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}


//获取推荐价格区间
export const getFilterRecommend = (params,fun)=> {
  wx.request({
    url: host + "/index.php?m=api&c=goods&a=getPriceInterval",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

//余额提现记录
export const WithdrawalRecord = (params,fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=get_cash_info",
    data: params,
    method: "POST",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 获取商品库存数量
export const getRepertory = (params,fun)=>{
  wx.request({
    url: host + "/index.php?m=api&c=api2&a=check_goods_number",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

// 取消订单
export const cellOrder = (params, fun) => {
  wx.request({
    url: host + "/index.php?m=api&c=user&a=cancel_order",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}

export const payPage = (params,fun)=> {
  wx.request({
    url: host + "/index.php?m=api&c=api2&a=get_express_time",
    data: params,
    method: "GET",
    dataType: "json",
    header: { "content-type": "application/x-www-form-urlencoded" },
    success: function (res) {
      if (res.data.code == resStatus) {
        return typeof fun === "function" && fun(true, res.data);
      } else {
        return typeof fun === "function" && fun(false, res.data);
      }
    },
    fail: function () {
      return typeof fun === "function" && fun(false)
    }
  });
}


